
#include "atomic_op_asm.h"

#ifdef _ARM_ARCH_6

ENTRY_NP(_atomic_or_8)
	mov	ip, r0
1:	ldrexb	r0, [ip]		/* load old value (to be returned) */
	orrs	r3, r0, r1		/* calculate new value */
	strexb	r2, r3, [ip]		/* try to store */
	cmp	r2, #0			/*   succeed? */
	bne	1b			/*     no, try again */
#ifdef _ARM_ARCH_7
	dmb
#else
	mcr	p15, 0, r2, c7, c10, 5	/* data memory barrier */
#endif
	RET				/* return old value */
END(_atomic_or_8)

ATOMIC_OP_ALIAS(atomic_or_8,_atomic_or_8)
ATOMIC_OP_ALIAS(atomic_or_char,_atomic_or_8)
CRT_ALIAS(__sync_fetch_and_or_1,_atomic_or_8)
CRT_ALIAS(__atomic_fetch_or_1,_atomic_or_8)
STRONG_ALIAS(_atomic_or_char,_atomic_or_8)

ENTRY_NP(_atomic_or_8_nv)
	mov	ip, r0			/* need r0 for return value */
1:	ldrexb	r0, [ip]		/* load old value */
	orrs	r0, r0, r1		/* calculate new value (return value) */
	strexb	r2, r0, [ip]		/* try to store */
	cmp	r2, #0			/*   succeed? */
	bne	1b			/*     no, try again? */
#ifdef _ARM_ARCH_7
	dmb
#else
	mcr	p15, 0, r2, c7, c10, 5	/* data memory barrier */
#endif
	RET				/* return new value */
END(_atomic_or_8_nv)

ATOMIC_OP_ALIAS(atomic_or_8_nv,_atomic_or_8_nv)
ATOMIC_OP_ALIAS(atomic_or_char_nv,_atomic_or_8_nv)
CRT_ALIAS(__sync_or_and_fetch_1,_atomic_or_8_nv)
STRONG_ALIAS(_atomic_or_char_nv,_atomic_or_8_nv)

#endif /* _ARM_ARCH_6 */
